//
//  ImageTableViewCell.m
//  SoundPill
//
//  Created by 宋旭东 on 15/6/9.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "ImageTableViewCell.h"

@implementation ImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.frame = CGRectMake(0, 0, self.frame.size.width / 2, self.frame.size.height);
        self.frame = CGRectMake(0, 0, (self.frame.size.width - 60) / 2, self.frame.size.height);
        self.backgroundColor = [UIColor whiteColor];
        [self createSubviews];
    }
    return self;
}
- (void)createSubviews
{
    self.imageShow = [[UIImageView alloc] initWithFrame:CGRectMake(0, 7, self.frame.size.width, self.frame.size.width)];
    _imageShow.backgroundColor = [UIColor whiteColor];
    [_imageShow setContentScaleFactor:_imageShow.contentScaleFactor];
    _imageShow.contentMode = UIViewContentModeScaleAspectFill;
    _imageShow.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    _imageShow.clipsToBounds  = YES;
    [self addSubview:_imageShow];
    
    self.imageType = [[UIImageView alloc] initWithFrame:CGRectMake( _imageShow.frame.size.width * 0.5, _imageShow.frame.size.height - _imageShow.frame.size.height * 0.15 + 7, _imageShow.frame.size.height * 0.5, _imageShow.frame.size.height * 0.15)];

    [self addSubview:_imageType];
    
    self.editImage = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self addSubview:_editImage];
    
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _imageShow.frame = CGRectMake(0, 7, self.frame.size.width, self.frame.size.width);
    
    _imageType.frame = CGRectMake( _imageShow.frame.size.width * 0.5, _imageShow.frame.size.height - _imageShow.frame.size.height * 0.15 + 7, _imageShow.frame.size.height * 0.5, _imageShow.frame.size.height * 0.15);
    
    _editImage.frame = CGRectMake(self.frame.size.width * 0.8, self.frame.size.width * 0.85, self.frame.size.width * 0.2, self.frame.size.width * 0.2);
}
@end
